package com.droidstouch.iweibo.ui;

import com.droidstouch.iweibo.logic.MainService;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.KeyEvent;


/**
 * Activity 基类
 * @author Administrator
 *
 */
public class BaseActitity extends Activity
{

	
	
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		
		if(keyCode== KeyEvent.KEYCODE_BACK)
		{
			
			alertExit();
		}
		
		return true;
	}
	
	
	
	
	public void alertExit()
	{
		
		
		Builder builder = new AlertDialog.Builder(this);
		
		builder.setTitle("退出系统");
		builder.setMessage("您确定退出微博吗");
		builder.setPositiveButton("确定", new OnClickListener()
		{
			
			@Override
			public void onClick(DialogInterface dialog, int which)
			{
				MainService.appExit(BaseActitity.this);
			}
		})
		.setNegativeButton("取消", new OnClickListener()
		{
			
			@Override
			public void onClick(DialogInterface dialog, int which)
			{
			
				 dialog.dismiss();
				
			}
		})
		;
		
		AlertDialog dialog = builder.create();
		dialog.show();
		
	}
	
	
	
	
	
	
}
